import { MOUNTED, UNMOUNTING, NOT_MOUNTED } from '../applications/app.helpers'

export async function toUnmountPromise(app) {
  // 当应用没有被挂载，直接什么也不做
  if (app.status !== MOUNTED) {
    return app
  }
  app.status = UNMOUNTING
  await app.unmount(app.customProps)
  app.status = NOT_MOUNTED
  return app
}